import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    indexData: null,
    goodsPage: false,  //首页展示首页还是商品列表组件
    goodsList: [],  //商品列表
    filterShow: false, //是否展示筛选侧边栏
    filterGoodsList: [],  //过滤的商品
    chooseShow: false,  //商品数量选择
    showBuy: false,  //商品数量选择
    // searchText: '', //搜索字符串
    address: null, //地址
    ishasfilterCondition: false, //是否有筛选条件的刷新
    filterToLoginGoods: false,  //让筛选的去加载数据
    bgColor: '252, 28, 28',  //背景色
    orderType: '',
    indexTopBarId: 0,
    orderGoods: null,
  },
  getters: {
  },
  mutations: {
    changeOrderGoods(state, params) {
      state.orderGoods = {
        waitPay: [...params.waitPay],
        waitSend: [...params.waitSend]
      }
    },
    changeIndexTopBarId(state, id) {
      state.indexTopBarId = id
    },
    changeOrderType(state, type) {
      state.orderType = type
    },
    changebgColor(state, color) {
      state.bgColor = color;
    },

    hasfilterCondition(state, type) {
      state.ishasfilterCondition = type;
    },
    filterToLoginGoodsHandler(state, type) {
      state.filterToLoginGoods = type;
    },
    toBuy(state, type) {
      state.showBuy = type;
    },
    changeAddress(state, data) {
      state.address = data;
    },
    keepIndexData(state, data) {
      state.indexData = data;
    },
    toGoodsPage(state, type) {
      // console.log(state);
      state.goodsPage = type;
    },
    haveGoodsList(state, list) {
      // console.log('list', list);
      state.goodsList = list
    },
    changeFilterShow(state, type) {
      state.filterShow = type;
    },
    changeFilterGoodsList(state, list) {
      state.filterGoodsList = list
    },
    changeChooseShow(state, type) {
      state.chooseShow = type;
    }
  },
  actions: {
  },
  modules: {
  }
})
